package main

import (
	"fmt"
	"net"
	"os"
)

func main()  {

	conn,errConn := net.Dial("tcp","127.0.0.1:8000")
	if errConn!=nil{
		fmt.Println("net.Dail err:",errConn)
	}
	defer conn.Close()
	go func() {
		buf:=make([]byte,1024)
		for{
			num,err:=os.Stdin.Read(buf)
			if err!=nil{
				fmt.Println("Stdin.Read err:",err)
			}
			fmt.Println("Stdin.Read num",num)
			conn.Write(buf[:num])
		}
	}()

	bufRead := make([]byte,1024)
	for{
		n,errRead := conn.Read(bufRead)
		if errRead != nil{
			fmt.Println("errRead:",errRead)
			return
		}
		fmt.Println("message from Server:",string(bufRead[:n]))
	}


}
